#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/11/29 22:31
# @function: the script is used to do something.
# @version :
import re

from bs4 import BeautifulSoup
import requests

url = 'https://movie.douban.com/top250'
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'

}
response = requests.get(url, headers=headers).text

# 创建bs4对象
soup = BeautifulSoup(response, 'lxml')
# print(soup)


"""
soup对象方法
"""
# 1.传递标签名称
# html_h1 = soup.find_all('h1')
# print(html_h1)
# 美化输出
# print(soup.prettify())

# 传字符串
# span = soup.find_all('span')
# print(span)

# 传正则表达式
# b_list = soup.find_all(re.compile('^b'))
# print(b_list)

# 传列表
# data = soup.find_all(['h1', 'span'])
# print(data)

# keyword参数
data = soup.find_all('div', attrs={'class': 'pic'})
print(data)
